#include <QSqlTableModel>
#include <QSqlDatabase>
#include <QSqlError>
#include <QDebug>

#include "routeserverform.h"


RouteserverForm::RouteserverForm(const QString & fileName)
{
    setupUi( this );

    QSqlDatabase dbData = QSqlDatabase::addDatabase("QSQLITE", "routeserver");
    dbData.setDatabaseName(fileName);
    if(dbData.open()){
        QSqlTableModel * model = new QSqlTableModel(this, dbData);
        model->setTable("routeserver");
        model->setEditStrategy(QSqlTableModel::OnFieldChange);
        model->select();
        routeserverTV->setModel(model);
    } else {
        //TODO log
        qDebug() << dbData.lastError().text();
    }
}

RouteserverForm::~RouteserverForm()
{
    QSqlDatabase db = QSqlDatabase::database("QSQLITE", "routeserver");
    if(db.isOpen())
        db.close();
}

void RouteserverForm::addNewRouteserver()
{
}

void RouteserverForm::removeRouteserver()
{
}
